package light

import (
	"light-pi/internal/gpio"
)

// 控制灯的开关
func ControlLight(isopen bool) error {
	opts := []gpio.Opt{}
	opts = append(opts, gpio.NoExportOnClose())
	pin, err := gpio.OpenPin(4, gpio.OUT, opts...)
	if err != nil {
		return err
	}
	defer pin.Close()
	if isopen {
		err = pin.Write(gpio.HIGH)
	} else {
		err = pin.Write(gpio.LOW)
	}
	return err
}
